const { join } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')
module.exports = {
  entry: './src/main.js',
  output: {
    path: join(__dirname, './dist'),
    filename: 'js/bundle.js'
  },
  resolve: {
    extensions: ['.js', '.json', '.vue', '.css']
  },
  target: 'web',
  mode: 'development',
  devServer: {
    open: true,
    host: '127.0.0.1',
    port: 3000,
    hot: true
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'style-loader',
          'css-loader',
          {
            loader: 'postcss-loader',
            options: {
              postcssOptions: {
                plugins: [require('postcss-preset-env')]
              }
            }
          }
        ]
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './public/index.html',
      title: 'webpack study'
    }),
    new VueLoaderPlugin()
  ]
}
